<script>
    nmenuindex=3;
</script>
<?php
	
 	include ('controller/JO_4rumController.php');
        $JO["forum"]= JO( array( "EN" => "Forum","VI"=>"Diễn Đàn") );
        $JO["topic"]= JO( array( "EN" => "Topic","VI"=>"Chủ Đề") );
        $JO["lastpost"]= JO( array( "EN" => "Last Posts","VI"=>"Bài Gửi Mới Nhất") );
        $JO["postnum"]= JO( array( "EN" => "Posts","VI"=>"Bài Viết") );
        $JO["commentnum"]= JO( array( "EN" => "Comment","VI"=>"Nhận Xét") );
        $JO["post"]= JO( array( "EN" => "Posts","VI"=>"Bài Viết") );
        $JO["lastcomment"]= JO( array( "EN" => "Last Comment","VI"=>"Nhận Xét Mới Nhất") );
        $JO["postby"]= JO( array( "EN" => "Post by","VI"=>"Đăng bởi") );
        $JO["postdate"]= JO( array( "EN" => "Post At","VI"=>"Ngày Đăng") );
        $JO["postnew"]= JO( array( "EN" => "+Add New Post","VI"=>"+Viết Bài Mới") );
        $JO["commentat"]= JO( array( "EN" => "Comment At","VI"=>"Nhận xét lúc") );

        ?>
        <div style="
             width: 960px;background: url(JO_images/hr.gif1) repeat-x top left #222;
             position: relative;float:left;

             ">
              <? include 'JO_007_nav1.php';?>

            <div class="mar8i"></div>
            <div style="
                 margin-left: 0px;
/*                 background: url(JO_images/333.png) repeat-y 487px 0px #1a1a1a;*/
                 " class="bar_720i">
                <div class="JO_h1i"><?=$JO["forum"].(isset($_REQUEST["topic"])?(" :: ".$_REQUEST["topic"]):"")?></div>
                <div class="mar8i"></div>
                <?
                if(!isset($_REQUEST["topic"])){
                ?>
                <table class="tbi" style="width: 704px;margin: 4px 0">
                    <tr>
                        <th style="width: 30px">#</th>
                        <th style="width: 200px"><?=$JO["topic"]?></th>
                        <th><?=$JO["lastpost"]?></th>
                        <th style="width: 60px"><?=$JO["postnum"]?></th>
                        <th style="width: 60px"><?=$JO["commentnum"]?></th>
                    </tr>
                    <?
                    $datatopic=forumModule::getTopicsOfComment();
                    if($datatopic==null){
                        echo "<tr><td colspan='5'>Data is updating</td></tr>";
                    }else{
                        foreach ($datatopic as $rowtopic){
                            ?>
                    <tr>
                        <th>
                            tag
                        </th>
                        <th style="font-weight: normal;color: #9d9d9d">
                            <a href="?JO_unit=011_Comment<?=isset($rowtopic["subject"])?("&topic=".$rowtopic["subject"]):""?>">
                            <span style="color: #C5E86A;font-weight: bold;"><?=isset($rowtopic["subject"])?$rowtopic["subject"]:""?></span>
                            <br/>
                            <?=isset($rowtopic["image"])?("<img style='max-width: 200px;margin:4px 0' src='".$rowtopic["image"])."' alt=''/><br/>":""?>
                            
                            <?=isset($rowtopic["description"])?$rowtopic["description"]:""?>
                            </a>
                        </th>
                        <td>
                            <br/>
                            <?=isset($rowtopic["articletitle"])?("<a href='?JO_unit=011_comment_detail".(isset($rowtopic["articlekey"])?("&article=".$rowtopic["articlekey"]):"")."'>".$rowtopic["articletitle"]."</a>"):"Data is updating"?><br/>
                            <?=isset($rowtopic["articleinsert"])?$rowtopic["articleinsert"]:""?>
                        </td>
                        <td><br/><?=isset($rowtopic["topicnum"])?$rowtopic["topicnum"]:"0"?></td>
                        <td><br/><?=isset($rowtopic["commentnum"])?$rowtopic["commentnum"]:"0"?></td>
                    </tr>
                            <?
                        }
                    }
                    ?>
                </table>


                <?
                }else{
                    
                }
                    //if(isset($_REQUEST["topic"])){
                        $_chude=isset($_REQUEST["topic"])?$_REQUEST["topic"]:null;
                        $page=isset($_REQUEST["page"])?$_REQUEST["page"]:1;
                        $num=10;
                        $datapostimportant=forumModule::getPosts_important($_chude,$num);
                        $datapost=forumModule::getPosts($_chude,$page,$num);
                        $npages=forumModule::getnumPosts($_chude,$num);
                    //}
                ?>

                <div style="
                     float: left;width: 704px;height: 24px;
                     margin-left: 8px;
                     line-height: 24px;
                     font-weight: bold;color: #C5E86A;
                     position: relative;
                     ">
                    <a href="?JO_unit=011_NewPost<?=isset($_REQUEST["topic"])?("&topic=".$_REQUEST["topic"]):""?>"><?=$JO["postnew"]?></a>

                </div>
                <table class="tbi" style="width: 704px;margin: 4px 0 4px 8px">
                    <tr>
                        <th style="width: 30px">#</th>
                        <th style="width: 300px"><?=$JO["post"]?></th>
                        <th><?=$JO["lastcomment"]?></th>
                        <th style="width: 60px"><?=$JO["topic"]?></th>
                        <th style="width: 60px"><?=$JO["commentnum"]?></th>
                    </tr>
                    <?
                    if($datapostimportant==null){ echo "<tr><td colspan=5>Data is updating</td></tr>";}
                    else foreach ($datapostimportant as $rowpostimportant){
                        ?>
                        <tr>
                            <th>
                                <?=$rowpostimportant["important"]?>
                            </th>
                            <th style="font-weight: normal;color: #EBEBEB">
                                <a href="?JO_unit=011_Comment_detail<?=isset($rowpostimportant["key"])?("&article=".$rowpostimportant["key"]):""?>"
                                   style=";font-weight: <?=(isset($rowpostimportant["important"]) && $rowpostimportant["important"]=="1")?"bold;color: #C5E86A;":"normal;"?>

                                   "
                                   >
                                <?=isset($rowpostimportant["title"])?$rowpostimportant["title"]:""?>
                                </a>
                                <span style="color: #7d7d7d">
                                    <br/>
                                    <?=$JO["postdate"]?> : <?=isset($rowpostimportant["insert"])?$rowpostimportant["insert"]:""?>
                                    <br/>
                                    <?=$JO["postby"]?> : <?=isset($rowpostimportant["name"])?$rowpostimportant["name"]:""?>
                                    </span>
                            </th>
                            <td>
                                
                                <?=isset($rowpostimportant["lastcomment"])?JO_UNconvertHTMLentities($rowpostimportant["lastcomment"]):"empty"?><br/>
                                <span style="color: #7d7d7d">
                                    <?=isset($rowpostimportant["lastcommentinsert"])?((isset($rowpostimportant["lastcommentaccountname"])?("\"".$rowpostimportant["lastcommentaccountname"]."\" "):"").$JO["commentat"].":".$rowpostimportant["lastcommentinsert"]):""?>
                                </span>
                            </td>
                            <td><br/><?=isset($rowpostimportant["subject"])?$rowpostimportant["subject"]:"Data is updating"?></td>
                            <td><br/><?=isset($rowpostimportant["commentnum"])?$rowpostimportant["commentnum"]:"0"?></td>
                        </tr>
                        <?
                    }
                    ?>
                    <?
                    if($datapost==null){ echo "<tr><td colspan=5>Data is updating</td></tr>";}
                    else foreach ($datapost as $rowpost){
                        ?>
                        <tr>
                            <th>
                                <?=$rowpost["important"]?>
                            </th>
                            <th style="font-weight: normal;color: #EBEBEB">
                                <a href="?JO_unit=011_Comment_detail<?=isset($rowpost["key"])?("&article=".$rowpost["key"]):""?>"
                                   style=";font-weight: <?=(isset($rowpost["important"]) && $rowpost["important"]=="1")?"bold;color: #C5E86A;":"bold;"?>
                                   
                                   "
                                   >
                                <?=isset($rowpost["title"])?$rowpost["title"]:""?>
                                </a>
                                <br/>
                                <span style="color: #7d7d7d">
                                    <?=$JO["postdate"]?> : <?=isset($rowpost["insert"])?$rowpost["insert"]:""?>
                                    <br/>
                                    <?=$JO["postby"]?> : <?=isset($rowpost["name"])?$rowpost["name"]:""?>
                                </span>
                            </th>
                            <td>
                                
                                <?=isset($rowpost["lastcomment"])?JO_UNconvertHTMLentities($rowpost["lastcomment"]):"empty"?><br/>
                                <span style="color: #7d7d7d">
                                    <?=isset($rowpost["lastcommentinsert"])?((isset($rowpost["lastcommentaccountname"])?("\"".$rowpost["lastcommentaccountname"]."\" "):"").$JO["commentat"].":".$rowpost["lastcommentinsert"]):""?>
                                </span>
                            </td>
                            <td><br/><?=isset($rowpost["subject"])?$rowpost["subject"]:"Data is updating"?></td>
                            <td><br/><?=isset($rowpost["commentnum"])?$rowpost["commentnum"]:"0"?></td>
                        </tr>
                        <?
                    }
                    ?>
                        
                                <?
                                if($datapost!=null){
                                    

                                    if($npages>1){
                                        echo "<tr><td colspan='5'><center>";
                                        if($page-5>1) echo "...";
                                        for($i=$page-5;$i<=($page+5);$i++){
                                            if($i>0 && $i<=$npages){
                                            echo "<a href='javascript:void(0);' class='JO_pagesi".(($i==$page)?" pageactive":"")."'>$i</a>";
                                            }
                                        }
                                        if($page+4<$npages) echo "...";

                                        echo "</center></td></tr>";
                                    }
                                    
                                }
                                ?>
                            
                </table>
                <div style="
                     float: left;width: 704px;height: 24px;
                     margin-left: 8px;
                     line-height: 24px;
                     font-weight: bold;color: #C5E86A;
                     position: relative;
                     ">
                    <a href="?JO_unit=011_NewPost<?=isset($_REQUEST["topic"])?("&topic=".$_REQUEST["topic"]):""?>"><?=$JO["postnew"]?></a>

                </div>
        </div>
           
    </div>
<script>
    function initpageclick(){
        $(".JO_pagesi").click(
            function(){
                sendurl($(this).html());
            }
        );

    }
    initpageclick();
    function sendurl(p){
        var url="?JO_unit=011_Comment<?=isset($_REQUEST["topic"])?"&topic=".$_REQUEST["topic"]:""?>";
        url+="&page="+p;
        location=url;
        
    }
</script>